package com.yanqu.road.server.cmd.activity.dafuweng.zaoyao;

import com.yanqu.road.entity.activity.dafuweng.DFWConfig;
import com.yanqu.road.pb.monopoly.MonopolyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.dafuweng.DaFuWengMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_DA_FU_WENG_ZAO_YAO_RESULT_FROM_CROSS, desc = "造谣结果")
public class DaFuWengZaoYaoResultFromCrossCmd extends AbstractCommand {

    int activityId;
    long doUserId;
    int result;
    int type;
    MonopolyProto.ZaoYaoSceneMsg sceneData;
    String unionUid;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MonopolyProto.CrossHandleZaoYaoRespMsg reqMsg = MonopolyProto.CrossHandleZaoYaoRespMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        doUserId = reqMsg.getDoUserId();
        result = reqMsg.getResult();
        type = reqMsg.getType();
        if (result == 0) {
            sceneData = reqMsg.getSceneData();
        }
        unionUid = reqMsg.getUnionUid();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DFWConfig dfwConfig = DaFuWengMgr.getDfwConfig();
        if (dfwConfig == null || !ActivityMgr.activityInTime(dfwConfig.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_DFW_NO_IN_TIME;
            return;
        }

        DaFuWengMgr.zaoYaoReturnFromCross(doUserId, type, result, sceneData, unionUid);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
